package com.ht.controller;

import cn.hutool.json.JSONUtil;
import com.ht.data.Result;
import com.ht.dto.UserDTO;
import com.ht.service.HomePageService;
import com.ht.util.JwtUtil;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * TODO 科普号主页接口
 */
@RestController
@RequestMapping("homePage")
@Api("科普号主页管理Api")
@RefreshScope //自动刷新配置文件
public class HomePageController {

    @Autowired
    private HomePageService homePageService;

    @GetMapping
    @ApiOperation(value = "根据当前登录用户查询关注")
    public Result findByUser(@RequestHeader("AuthToken")String token){
        Claims claims = new JwtUtil().parseJwt(token);
        UserDTO userDTO = JSONUtil.toBean(claims.getSubject(), UserDTO.class);
        Result result = homePageService.findByUserId(userDTO.getId());
        return null;
    }

}
